/**
 * Definition for singly-linked list.
 * function ListNode(val) {
 *     this.val = val;
 *     this.next = null;
 * }
 */

/**
 * @param {ListNode} headA
 * @param {ListNode} headB
 * @return {ListNode}
 */

var getIntersectionNode = function (headA, headB) {
  const A = headA,
    B = headB;
  while (headA !== headB) {
    if (headA === null) {
      headA = B;
    } else {
      headA = headA.next;
    }
    if (headB === null) {
      headB = A;
    } else {
      headB = headB.next;
    }
  }
  return headA;
};

console.log(null===null)

var getIntersectionNode = function(headA, headB) {
    const A = headA,B = headB
    while(headA!==headB){
        if(headA===null){
            headA = B
        }else{
            headA=headA.next
        }
        if(headB===null){
            
            headB = A
        }else{
            headB=headB.next
        }
    }
    return headA
};

